//
//  ZH_MineOrderGoodsInfoTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/22.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineOrderGoodsInfoTableViewCell.h"
@interface ZH_MineOrderGoodsInfoTableViewCell()
@property (nonatomic,weak)UIImageView *iconImage;
@property (nonatomic,weak)UILabel *parameterLabel;
@property (nonatomic,weak)UILabel *priceLabel;
@property (nonatomic,weak)UILabel *numLabel;
@property (nonatomic,weak)UILabel *titleLabel;
@property (nonatomic,weak)UIButton *backButton;
@end
@implementation ZH_MineOrderGoodsInfoTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_MineOrderGoodsInfoTableViewCell";
    ZH_MineOrderGoodsInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_MineOrderGoodsInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomShortLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(13));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.height.mas_equalTo(FITSCALE(82));
        make.width.mas_equalTo(FITSCALE(82));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-9));
    }];
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(13));
        make.right.equalTo(self.contentView).offset(FITSCALE(-10));
        make.height.mas_equalTo(FITSCALE(30));
        make.width.mas_equalTo(FITSCALE(82));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImage);
        make.left.equalTo(self.iconImage.mas_right).offset(10);
        make.right.equalTo(self.backButton.mas_left);
    }];
    [self.parameterLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(FITSCALE(15));
        make.left.equalTo(self.titleLabel);
        make.right.equalTo(self.titleLabel);
    }];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.parameterLabel.mas_bottom).offset(FITSCALE(20));
        make.left.equalTo(self.titleLabel);
    }];
    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.priceLabel);
        make.left.equalTo(self.priceLabel.mas_right).offset(FITSCALE(20));
    }];

}
#pragma mark - getter,setter
- (UIImageView *)iconImage{
    if (!_iconImage) {
        UIImageView *image = [[UIImageView alloc] init];
        image.backgroundColor = [UIColor redColor];
        image.image = [UIImage imageNamed:@""];
        image.layer.cornerRadius = 3;
        image.layer.masksToBounds = YES;
        image.clipsToBounds = YES;
        [self.contentView addSubview:_iconImage = image];
    }
    return _iconImage;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.text = @"商品名称";
        [label setNumberOfLines:2];
        label.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_titleLabel = label];
    }
    return _titleLabel;
}
- (UILabel *)parameterLabel{
    if (!_parameterLabel) {
        UILabel *label = [UILabel createLabelWithText:@"商品参数..." font:kFontSize_26];
        [self.contentView addSubview:_parameterLabel = label];
    }
    return _parameterLabel;
}
- (UILabel *)priceLabel{
    if (!_priceLabel) {
        UILabel *label = [UILabel createLabelWithText:@"￥100" font:kFontSize_26];
        label.textColor = [UIColor colorWithHexString:@"#F0302F"];
        [self.contentView addSubview:_priceLabel = label];
    }
    return _priceLabel;
}
- (UILabel *)numLabel{
    if (!_numLabel) {
        UILabel *label = [UILabel createLabelWithText:@"X1" font:kFontSize_24];
        label.textColor = [UIColor colorWithHexString:@"#999999"];
        [self.contentView addSubview:_numLabel = label];
    }
    return _numLabel;
}
- (UIButton *)backButton{
    if (!_backButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"申请退款" target:self action:nil];
        button.backgroundColor = kFontColorWhite;
        [button setTitleColor:[UIColor colorWithHexString:@"#00C9AE"] forState:UIControlStateNormal];
        button.layer.cornerRadius = FITSCALE(14);
        button.layer.masksToBounds = YES;
        button.clipsToBounds = YES;
        button.titleLabel.font = kFontSize_28;
        [self.contentView addSubview:_backButton = button];
    }
    return _backButton;
}
@end
